home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 11371 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.7 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: compilers
  5. Date: Fri, 22 Mar 96 20:45:27 GMT
  6. Organization: none
  7. Message-ID: <827527527snz@genesis.demon.co.uk>
  8. References: <4iburm$aps@airdmhor.gen.nz> <DoBvF6.GG5@iquest.net> <4ihcld$iln@airdmhor.gen.nz>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: genesis.demon.co.uk
  13.  
  14. In article <4ihcld$iln@airdmhor.gen.nz>
  15.            gumboot@airdmhor.gen.nz "Simon Hosie" writes:
  16.  
  17. >gumboot@airdmhor.gen.nz (Simon Hosie) wrote:
  18. >>   Does anyone know of a compiler that can take
  19. >> 
  20. >> for (;;)
  21. >> {
  22. >>     Stuff(1);
  23. >>     if (Cond)
  24. >>         break;
  25. >>     Stuff(2);
  26. >> }
  27. >> 
  28. >>   and make
  29. >> 
  30. >> goto EntryPoint;
  31. >> do
  32. >> {
  33. >>     Stuff(2);
  34. >> EntryPoint:
  35. >>     Stuff(1);
  36. >> } while (Cond);
  37. >
  38. >Doug Miller:
  39. >> A possibly more important question is why you would want it to, since the
  40. > first form is vastly
  41. >> more comprehensible.
  42. >
  43. >  Well, it would compile it, so you'd never get to see the difference, but
  44. >the latter has only 1 conditional jump and no 'definite'jumps in the inner 
  45. >loop whereas the former has 1 conditial jump (not usually taken) and a
  46. >'definite' jump.
  47.  
  48. And it is one of the more trivial optimisations for a compiler to rearrange
  49. loops for efficiency. Concern yourself with clarity in the source code - let
  50. the compiler deal with generating efficient object code. It may even find
  51. a better way than generating code equivalent to the 2nd form so it is
  52. unwise to 2nd guess it.
  53.  
  54. -- 
  55. -----------------------------------------
  56. Lawrence Kirby | fred@genesis.demon.co.uk
  57. Wilts, England | 70734.126@compuserve.com
  58. -----------------------------------------
  59.